/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * frm_JInterFrameQuanLyPhim.java
 *
 * Created on Aug 2, 2011, 5:52:07 PM
 */

package GUI;

import java.util.ArrayList;
import java.util.Vector;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import POJO.PhongPOJO;
import DAO.PhongDAO;
import POJO.RapPOJO;
import DAO.RapDAO;


/**
 *
 * @author HP
 */
public class frm_JInterFrameQuanLyPhong extends javax.swing.JInternalFrame {

    /** Creates new form frm_JInterFrameQuanLyPhim */
// <editor-fold defaultstate="collapsed" desc="1. Cac Thuoc Tinh">
    ArrayList<RapPOJO> dsrap=new ArrayList<RapPOJO>();
    RapDAO rapdao=new RapDAO();
    PhongDAO phdao=new PhongDAO();
    ArrayList<PhongPOJO> dsphong=new ArrayList<PhongPOJO>();
    DefaultTableModel dftablemodel =new DefaultTableModel();//Doi tuong thao tac dong cot cua table
    int stt=1;
// </editor-fold>
   /**
    * Ham Khoi Tao Cac Cot Cho jtbldsphong
    */
    private void InitColumTable()
    {
        dftablemodel.addColumn("STT");
        dftablemodel.addColumn("Mã phòng");
        dftablemodel.addColumn("Tên phòng");
        dftablemodel.addColumn("Số lượng ghế");
        dftablemodel.addColumn("Tình trạng phòng");
        this.jtblDSPhong.setModel(dftablemodel);
    }
/**
 * Ham Khoi Tao cua Form (Khi run thi ham nay dc chay dau tien)
 */
    public frm_JInterFrameQuanLyPhong() {
        initComponents();
        //InitColumTable();
    }
/**
 *Ham Khoi Tao Cac Gia Tri Cho Combobox
 */
    private void Init()
    {
        try
        {
            DefaultComboBoxModel dfcbxRap=new DefaultComboBoxModel();
           
            dsrap=rapdao.layDanhRapCacMaRap();

            for(RapPOJO i: dsrap)
            {
                Vector vt=new Vector();
                vt.add(i.getMaRap());
                vt.add(i.getTenRap());
                //them mot dong voao model
                dfcbxRap.addElement(vt);
            }
            this.jcmbxRapChieu.setModel(dfcbxRap);

        }
        catch(Exception ex)
        {
            JOptionPane.showMessageDialog(this, ex.getMessage(),"Đã xảy ra lỗi",JOptionPane.ERROR_MESSAGE);
        }
    }
/**
 * Ham Xoa Cac Dong Trong table ( quan trong lam do)
 * Muc dich: trong table co nhieu dong trong do,muon khoi tao lai cac gia tri table moi hoan toan
 * thi phai su dung ham nay de xoa tat ca cac dong hien co trong table
 */
//public void ClearTabledsphong()
//{
//
//    javax.swing.table.DefaultTableModel mode=(DefaultTableModel) this.jtblDSPhong.getModel();
//   
//    for (int i=jtblDSPhong.getRowCount()-1;i>=0;i--)
//    {
//         mode.removeRow(i);
////
//    }
//}

 private void HienThiDanhSachPhong()
{
    dsphong=phdao.layDanhPhongCacMaPhong();
    //ClearTabledsphong() ;
//     InitColumTable();
//     jtblDSPhong.removeAll();
//     DefaultTableModel mode=new DefaultTableModel();

    javax.swing.table.DefaultTableModel model=(DefaultTableModel) this.jtblDSPhong.getModel();
    stt=1;
     for(PhongPOJO i : dsphong )
     {
         Vector vt=new Vector();
         vt.add(stt);
         vt.add(i.getMaPhong());
         vt.add(i.getTenPhong());
         vt.add(i.getSoLuongGhe());
         vt.add(i.getTrangThai());
         model.addRow(vt);
         stt++;
     }
    this.jtblDSPhong.setModel(dftablemodel);
}
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jpnThongTinQuanLyPhong = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jtxtSoLuong = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jcmbxRapChieu = new javax.swing.JComboBox();
        jtxtTinhTrang = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jtxtTenPhong = new javax.swing.JTextField();
        jbtnSuaphong = new javax.swing.JButton();
        jbtnThemphong = new javax.swing.JButton();
        jbtnXoa = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jtxtMaPhong = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtblDSPhong = new javax.swing.JTable();

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        setTitle("Quản lý phòng");
        setDoubleBuffered(true);
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameOpened(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(255, 204, 204));

        jPanel2.setBackground(new java.awt.Color(204, 204, 255));

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        jLabel8.setText("QUẢN LÝ PHÒNG CHIẾU ");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(240, 240, 240)
                .addComponent(jLabel8)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jLabel8)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jpnThongTinQuanLyPhong.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 255), 2), "Thông tin phòng"));

        jLabel3.setText("Số lượng ghế");

        jLabel1.setText("Rạp chiếu");

        jLabel4.setText("Tình trạng phòng");

        jLabel7.setText("Tên phòng");

        jbtnSuaphong.setText("Sửa");
        jbtnSuaphong.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnSuaphongActionPerformed(evt);
            }
        });

        jbtnThemphong.setText("Thêm");
        jbtnThemphong.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnThemphongActionPerformed(evt);
            }
        });

        jbtnXoa.setText("Xóa");
        jbtnXoa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnXoaActionPerformed(evt);
            }
        });

        jLabel2.setText("Mã phòng");

        jtxtMaPhong.setEnabled(false);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addGap(35, 35, 35)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel7)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel2))
                                .addGap(37, 37, 37))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jLabel4)
                                .addGap(18, 18, 18)))
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jtxtTinhTrang, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jtxtSoLuong)
                            .addComponent(jtxtTenPhong)
                            .addComponent(jcmbxRapChieu, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jtxtMaPhong)))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(38, 38, 38)
                        .addComponent(jbtnThemphong, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jbtnXoa, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jbtnSuaphong, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap(25, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jtxtMaPhong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jcmbxRapChieu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtxtTenPhong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addGap(12, 12, 12)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3)
                    .addComponent(jtxtSoLuong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jtxtTinhTrang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addGap(45, 45, 45)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE, false)
                    .addComponent(jbtnXoa, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jbtnSuaphong, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jbtnThemphong, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(45, 45, 45))
        );

        javax.swing.GroupLayout jpnThongTinQuanLyPhongLayout = new javax.swing.GroupLayout(jpnThongTinQuanLyPhong);
        jpnThongTinQuanLyPhong.setLayout(jpnThongTinQuanLyPhongLayout);
        jpnThongTinQuanLyPhongLayout.setHorizontalGroup(
            jpnThongTinQuanLyPhongLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnThongTinQuanLyPhongLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jpnThongTinQuanLyPhongLayout.setVerticalGroup(
            jpnThongTinQuanLyPhongLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnThongTinQuanLyPhongLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(51, 51, 255), 2), "Danh sách phòng"));

        jtblDSPhong.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jtblDSPhong.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jtblDSPhongMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jtblDSPhong);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 453, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(4, 4, 4)
                .addComponent(jpnThongTinQuanLyPhong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jpnThongTinQuanLyPhong, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents
/**
 * Ham formInternalFrameOpened giong nhu su kiem form load 
 * @param evt
 */
    private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameOpened
        // TODO add your handling code here:
        try
        {

             Init();
             //ShowSach();
             HienThiDanhSachPhong();
        }
        catch(Exception ex)
        {
            JOptionPane.showMessageDialog(this, ex.getMessage(),"Đã xảy ra lỗi",JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_formInternalFrameOpened

    private void jbtnThemphongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnThemphongActionPerformed
        // TODO add your handling code here:
        try{
            Vector marap=(Vector) this.jcmbxRapChieu.getSelectedItem();
            int ma =(Integer)marap.get(0);
            
            PhongPOJO pdto=new PhongPOJO();

            pdto.setMaRap(ma);
            pdto.setTenPhong(this.jtxtTenPhong.getText());
            pdto.setSoLuongGhe(Integer.parseInt(this.jtxtSoLuong.getText()));
            pdto.setTrangThai(Integer.parseInt(this.jtxtTinhTrang.getText()));

            if(phdao.themPhong(pdto)==true)
            {
               Vector vt=new Vector();
               vt.add(stt++);
               vt.add(pdto.getMaRap());
               vt.add(pdto.getTenPhong());
               vt.add(pdto.getSoLuongGhe());
               vt.add(pdto.getTrangThai());
               this.dftablemodel.addRow(vt);
            }

        }catch(Exception ex)
        {
             JOptionPane.showMessageDialog(this, ex.getMessage(),"Đã xảy ra lỗi",JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_jbtnThemphongActionPerformed
/**
 * Ham jtbldsphongMouseClicked : Lay dong duoc chon trong table
 * va lay ra tung thuoc tinh cua dong trng table va hien thi len cac textbox
 * @param evt
 */
    private void jtblDSPhongMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jtblDSPhongMouseClicked
        // TODO add your handling code here:
        try{
            int vt=this.jtblDSPhong.getSelectedRow();
            //int maphong= (Integer) this.jtblDSPhong.getValueAt(vt,1);
            String tenphong=(String) this.jtblDSPhong.getValueAt(vt, 2);
            //float soluongghe=Float.parseFloat(this.jtblDSPhong.getValueAt(vt, 3).toString().trim());
            //int tinhtrang=(Integer)this.jtblDSPhong.getValueAt(vt, 4);
            this.jtxtMaPhong.setText(this.jtblDSPhong.getValueAt(vt,1).toString());
            this.jtxtTenPhong.setText(tenphong);
            this.jtxtSoLuong.setText(this.jtblDSPhong.getValueAt(vt, 3).toString());
            this.jtxtTinhTrang.setText(this.jtblDSPhong.getValueAt(vt, 4).toString());
            
           
        }catch(Exception ex)
        {
              JOptionPane.showMessageDialog(this, ex.getMessage(),"Đã xảy ra lỗi",JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_jtblDSPhongMouseClicked
/**
 * Ham jbtnXoaSachActionPerformed xoa Sach theo ma sach
 * @param evt
 */
    private void jbtnXoaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnXoaActionPerformed
        // TODO add your handling code here:
        try
        {
           String ma= this.jtxtMaPhong.getText();
           if(phdao.xoaPhong(ma))
           {
                JOptionPane.showMessageDialog(this,"Xóa sách thành công", "Thống báo",JOptionPane.DEFAULT_OPTION);
                HienThiDanhSachPhong();
                this.jtxtMaPhong.setText("");
                this.jtxtTenPhong.setText("");
                this.jtxtSoLuong.setText("");
                this.jtxtTinhTrang.setText("");
           }
        }catch(Exception ex)
        {
              JOptionPane.showMessageDialog(this, ex.getMessage(),"Đã xảy ra lỗi",JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_jbtnXoaActionPerformed

    private void jbtnSuaphongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnSuaphongActionPerformed
        // TODO add your handling code here:
        try
        {
            Vector vtrap=(Vector) this.jcmbxRapChieu.getSelectedItem();
            int marap=(Integer)vtrap.get(0);

            PhongPOJO pdto=new PhongPOJO();
            pdto.setMaPhong(Integer.parseInt(this.jtxtMaPhong.getText()));
            pdto.setMaRap(marap);
            pdto.setTenPhong(this.jtxtTenPhong.getText());
            pdto.setSoLuongGhe(Integer.parseInt(this.jtxtSoLuong.getText()));
            pdto.setTrangThai(Integer.parseInt(this.jtxtTinhTrang.getText()));
            if(phdao.capNhatPhong(pdto))
            {
                JOptionPane.showMessageDialog(this,"Cập nhật thành công", "Thống báo",JOptionPane.DEFAULT_OPTION);
                HienThiDanhSachPhong();
            }

        }catch(Exception ex)
        {
         JOptionPane.showMessageDialog(this, ex.getMessage(),"Đã xảy ra lỗi",JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_jbtnSuaphongActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jbtnSuaphong;
    private javax.swing.JButton jbtnThemphong;
    private javax.swing.JButton jbtnXoa;
    private javax.swing.JComboBox jcmbxRapChieu;
    private javax.swing.JPanel jpnThongTinQuanLyPhong;
    private javax.swing.JTable jtblDSPhong;
    private javax.swing.JTextField jtxtMaPhong;
    private javax.swing.JTextField jtxtSoLuong;
    private javax.swing.JTextField jtxtTenPhong;
    private javax.swing.JTextField jtxtTinhTrang;
    // End of variables declaration//GEN-END:variables

}
